package com.itheima;

import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Properties;

public class getPropertiesInfo {
    @Test
    // 读取配置文件内容
    public void testGetPropertiesInfo() throws Exception {
        Properties properties = new Properties();
        properties.load(new FileReader("src/main/resources/users.properties"));
        System.out.println(properties.getProperty("admin"));
    }

    @Test
    // 写入到配置文件中
    public void testSetPropertiesInfo() throws Exception {
        Properties properties = new Properties();
        properties.setProperty("user",  "haha");
        properties.store(new FileWriter("src/main/resources/users2.properties", true), "users");
    }
    // 使用 Dom4j 框架提供xml 解析器对象
}
